package com.example.wechat.model;

import android.os.Parcel;
import android.os.Parcelable;
import java.util.ArrayList;
import java.util.List;

public class Moment implements Parcelable {
    private String id;
    private String userName;
    private String userAvatar;
    private String content;
    private List<String> images;
    private long time;
    private String location;
    private List<String> likes;
    private List<Comment> comments;
    private boolean isLiked;

    public Moment() {
        this.images = new ArrayList<>();
        this.likes = new ArrayList<>();
        this.comments = new ArrayList<>();
        this.isLiked = false;
    }

    public Moment(String id, String userName, String userAvatar, String content, 
                 List<String> images, long time, String location) {
        this.id = id;
        this.userName = userName;
        this.userAvatar = userAvatar;
        this.content = content;
        this.images = images != null ? images : new ArrayList<>();
        this.time = time;
        this.location = location;
        this.likes = new ArrayList<>();
        this.comments = new ArrayList<>();
        this.isLiked = false;
    }

    protected Moment(Parcel in) {
        id = in.readString();
        userName = in.readString();
        userAvatar = in.readString();
        content = in.readString();
        images = in.createStringArrayList();
        time = in.readLong();
        location = in.readString();
        comments = in.createTypedArrayList(Comment.CREATOR);
        isLiked = in.readByte() != 0;
        likes = in.createStringArrayList();
    }

    public static final Creator<Moment> CREATOR = new Creator<Moment>() {
        @Override
        public Moment createFromParcel(Parcel in) {
            return new Moment(in);
        }

        @Override
        public Moment[] newArray(int size) {
            return new Moment[size];
        }
    };

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(id);
        dest.writeString(userName);
        dest.writeString(userAvatar);
        dest.writeString(content);
        dest.writeStringList(images);
        dest.writeLong(time);
        dest.writeString(location);
        dest.writeTypedList(comments);
        dest.writeByte((byte) (isLiked ? 1 : 0));
        dest.writeStringList(likes);
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getUserAvatar() {
        return userAvatar;
    }

    public void setUserAvatar(String userAvatar) {
        this.userAvatar = userAvatar;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public List<String> getImages() {
        return images;
    }

    public void setImages(List<String> images) {
        this.images = images;
    }

    public long getTime() {
        return time;
    }

    public void setTime(long time) {
        this.time = time;
    }

    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    public List<String> getLikes() {
        return likes;
    }

    public void setLikes(List<String> likes) {
        this.likes = likes;
    }

    public List<Comment> getComments() {
        return comments;
    }

    public void setComments(List<Comment> comments) {
        this.comments = comments;
    }

    public boolean isLiked() {
        return isLiked;
    }

    public void setLiked(boolean liked) {
        isLiked = liked;
    }

    public String getUserId() {
        return id;
    }

    public void setUserId(String id) {
        this.id = id;
    }

    public List<String> getImageUrls() {
        return images;
    }

    public void setImageUrls(List<String> images) {
        this.images = images;
    }
} 